var lastGroupId = "";
var lastMenuId = "";
var lastHelpId = "";

function menuToggle(menuid, groupid) {
	if (lastMenuId == menuid)
		return;

	if (lastMenuId != ""&&document.getElementById(lastMenuId)!=undefined)
		document.getElementById(lastMenuId).getElementsByTagName("a")[0].className = "normal";

	document.getElementById(menuid).getElementsByTagName("a")[0].className = "ag";
	document.getElementById(groupid).getElementsByTagName("a")[0].className = "ag";

	lastMenuId = menuid;
	lastHelpId = menuid;
}

function DoMenu(emid) {
	var obj = document.getElementById("ul" + emid);

	if (obj.className.toLowerCase() == "expanded") {
		obj.className = "collapsed";
		document.getElementById(emid).getElementsByTagName("a")[0].className = "normal";
	} else {
		obj.className = "expanded";
		document.getElementById(emid).getElementsByTagName("a")[0].className = "ag";
	}

	if (lastGroupId != "" && emid != lastGroupId) {// �ر���һ��Menu
		if(document.getElementById(lastGroupId)!=undefined){
		document.getElementById("ul" + lastGroupId).className = "collapsed";
		document.getElementById(lastGroupId).getElementsByTagName("a")[0].className = "nomal";
		}
	}

	lastGroupId = emid;
	lastHelpId = emid;
}

function loadCard(transName, transId) {

	// 销毁已经加载的对象
	if (targetPanel.layout.activeItem!=undefined) {
		targetPanel.remove(targetPanel.layout.activeItem, true);
	}

	// 加载交易页面
	targetPanel.setTitle(transName);
	targetPanel.load({
				url : transId,
				text : '正在打开页面，请稍候.....',
				method : 'GET',
				nocache : true,
				scripts : true,
				timeout : 250
			});
}

function loadTab(transName, transId) {

	var n = targetPanel.getComponent(transId);

	// var t=new Ext.TabPanel();
	if (!n) {
		targetPanel.remove(n, true);
	}
	n = targetPanel.add({
				'id' : transId,
				'title' : transName,
				closable : true,
				autoScroll : true,
				layout : 'fit',
				autoLoad : {
					url : transId,
					text : '正在打开页面，请稍候.....',
					method : 'GET',
					nocache : true,
					scripts : true,
					timeout : 250
				}

			});

	// }
	targetPanel.setActiveTab(n);

}

function doTransaction(transName, transId) {

	if (Main_loadType == 'card') {
		loadCard(transName, transId);
	} else {
		loadTab(transName, transId);
	}

	return;

}
